<Project>
  <PropertyGroup Condition="'$(TestUsingWorkloads)' == 'true'">
    <!-- for non-ci builds, we install the sdk when tests are run -->
    <InstallWorkloadForTesting Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(ArchiveTests)' == 'true'">true</InstallWorkloadForTesting>
  </PropertyGroup>

  <PropertyGroup>
    <BuiltNuGetsDir>$([MSBuild]::NormalizeDirectory($(ArtifactsDir), 'packages', $(Configuration), 'Shipping'))</BuiltNuGetsDir>

    <DotNetInstallArgumentsForWorkloadsTesting Condition="!$([MSBuild]::IsOSPlatform('windows'))"
            >$(_DotNetInstallScriptPath) -i $(_SdkWithNoWorkloadPath) -v latest -q daily --channel 9.0</DotNetInstallArgumentsForWorkloadsTesting>
    <DotNetInstallArgumentsForWorkloadsTesting Condition="$([MSBuild]::IsOSPlatform('windows'))"
            >$(_DotNetInstallScriptPath) -InstallDir $(_SdkWithNoWorkloadPath) -Quality daily -Channel 9.0</DotNetInstallArgumentsForWorkloadsTesting>

    <VersionBandForManifestPackages>$(SdkBandVersionForWorkload_FromRuntimeVersions)</VersionBandForManifestPackages>
  </PropertyGroup>

  <ItemGroup>
    <!-- Required for running apps built with 9.0 sdk, but the sdk does
         not yet support *running* with 9.0 sdk -->
    <AdditionalSharedFrameworkToInstallArguments Include="-Version latest -Channel 8.0 -Quality daily" />

    <DefaultPropertiesForNuGetBuild Include="TargetOS=$(TargetOSForWorkload)" />
    <DefaultPropertiesForNuGetBuild Include="TargetArchitecture=$(TargetArchitectureForWorkload)" />
  </ItemGroup>

  <Target Name="_GetNuGetToBuildForTargetingPack" Returns="@(NuGetsToBuildForWorkloadTesting)" Condition="'$(PreparePackagesForWorkloadInstall)' == 'true'">
    <ItemGroup>
      <NuGetsToBuildForWorkloadTesting Include="$(BuiltNuGetsDir)Microsoft.NETCore.App.Ref.$(PackageVersionForWorkloadManifests).nupkg"
                      Project="$(InstallerProjectRoot)pkg/sfx/Microsoft.NETCore.App\Microsoft.NETCore.App.Ref.sfxproj"
                      Properties="@(DefaultPropertiesForNuGetBuild, ';')"
                      Descriptor="Ref pack"/>
    </ItemGroup>
  </Target>

  <!-- TODO: stamps -->
  <Target Name="_InstallSharedFrameworksForWorkloadTesting" AfterTargets="ProvisionDotNetForWorkloadTesting">
    <Exec Condition="'%(AdditionalSharedFrameworkToInstallArguments.Identity)' != '' and !$([MSBuild]::IsOSPlatform('windows'))"
          IgnoreStandardErrorWarningFormat="true"
          Command="$(_DotNetInstallScriptPath) -InstallDir $(_SdkWithNoWorkloadPath) -Runtime dotnet -SkipNonVersionedFiles %(AdditionalSharedFrameworkToInstallArguments.Identity)" />

    <Exec Condition="'%(AdditionalSharedFrameworkToInstallArguments.Identity)' != '' and $([MSBuild]::IsOSPlatform('windows'))"
          IgnoreStandardErrorWarningFormat="true"
          Command='powershell -ExecutionPolicy ByPass -NoProfile -command "&amp; $(_DotNetInstallScriptPath) -InstallDir $(_SdkWithNoWorkloadPath) -Runtime dotnet -SkipNonVersionedFiles %(AdditionalSharedFrameworkToInstallArguments.Identity)"' />
  </Target>

  <Import Project="$(MonoProjectRoot)nuget\Microsoft.NET.Runtime.WorkloadTesting.Internal\Sdk\WorkloadTesting.Core.targets" />
  <Import Project="$(MSBuildThisFileDirectory)workloads-wasi.targets" Condition="'$(RIDForWorkload)' == 'wasi-wasm'" />
  <Import Project="$(MSBuildThisFileDirectory)workloads-browser.targets" Condition="'$(RIDForWorkload)' == 'browser-wasm'" />
</Project>
